<div class="col-lg-2">
</div>
<div class="col-lg-8 blog">
  <div class="blog-header">
    <h1><%=h params[:id] == "blog" ? I18n.t('tag.blog.the_public_lab') : params[:id].split('-').join(' ').capitalize %> <%=raw translation('tag.blog.blog') %></h1>

    <% if params[:id] == "blog" %>
      <br />
      <p><%=raw translation('tag.blog.stories_from_community') %></p>
      <p>
        <a href="/wiki/blog"><%=raw translation('tag.blog.about_the_blog') %>  </a> |
        <a href="/research"><%=raw translation('tag.research') %> </a> |
        <a href="/tools"><%=raw translation('tag.methods') %></a>
      </p>
      <% if current_user %>
        <a class="btn btn-outline-secondary btn-sm" href="/feed/tag/<%=h params[:id] %>.rss"><i class="fa fa-rss"></i> RSS</a>
        <% if current_user.following(params[:id]) %>
        <a rel="tooltip" title="<%= translation('tag.blog.unfollow',{},false) %>" class="btn btn-outline-secondary btn-sm active" href="/unsubscribe/tag/<%=h params[:id] %>" data-method="delete"><i class="fa fa-user-plus" aria-hidden="true"></i> <%= translation('tag.blog.following') %> <b><%=h params[:id] %></b></a>
        <% else %>
          <br><br>
          <div class="alert alert-success" role="alert">
            Want to get updates for new blog posts? <a class="btn btn-outline-secondary btn-sm" href="/subscribe/tag/<%=h params[:id] %>">
            <b><%=raw translation('Click here to subscribe!') %></b></a>
          </div>
        <% end %>
      <% else %>
        <div class="alert alert-info" role="alert">
        <a data-toggle="modal" data-target="#loginModal">Log in</a> to get updates for new posts!
        </div>
      <% end %>
    <% end %>

    <br />

  </div>

  <hr />

  <% if @notes.nil? || @notes.length == 0 %>
    <p><%= raw translation('tag.blog.no_results', :search => sanitize(params[:id])) %>:</p>

    <%= render template: "search/new" %>

  <% else %>

      <% @notes.each_with_index do |node,i| %>
        <div class="clearfix blog-entry">
          <% if node.main_image %>
              <a class="img" href="<%= node.path %>"><%= image_tag(node.main_image.path(:default)) %></a>
          <% end %>
          <h1><a href="<%= node.path %>"><%= node.title %></a></h1>
          <p class="meta" style="color:#888;"><small>
            <%=raw translation('tag.blog.by') %> <a href="/profile/<%= node.author.name %>"><%= node.author.name %></a>  <%= node.author.new_contributor %>
	    <% if node.has_power_tag('with') %>with <% node.coauthors.each_with_index do |coauthor,i| %>
              <a href="/profile/<%= coauthor.username %>">
              <%= coauthor.username%></a> <%= coauthor.new_contributor %>
              <%= ',' if i < node.coauthors.length-1 %><% end %><% end %>
	    | <%= distance_of_time_in_words(node.created_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %>
            | <a href="<%= node.path %>#comments"><i style="color:#888;" class="fa fa-comment-o"></i> <%= node.comments_viewable_by(current_user).length %></a>
            <% if params[:controller] == "notes" && params[:action] == "popular" %>
            | <%= number_with_delimiter(node.views) %> <%=raw translation('tag.blog.views') %>
            <% else %>
            | <i style="color:#888;" class="fa fa-star-o"></i> <%= node.likes %>
            <% end %>
          </small></p>
          <p><%= raw auto_link(insert_extras(node.latest.render_body), :sanitize => false) %></p>
          <p><a class="btn btn-outline-secondary btn-md" href="<%= node.path %>" style="color: black"><%=raw translation('tag.blog.read_more')%> <i class="fa fa-angle-double-right"></i></a><%= render partial: 'tag/subscribe_button', locals:{tags: node.tags, index: i} %></p>
          <p>
            <%= render :partial => "like/like", :locals => {:node => node, :tagnames => node.tags.collect(&:name) } %>
            <% node.tags[0..3].each do |tag| %>
              <a class="badge badge-primary" href="/tag/<%= tag.name %>"><%= tag.name %></a>
            <% end %>
          </p>
          <% if params[:mod] %>
          <a class="btn btn-outline-secondary btn-sm" href="#"><i class="fa fa-ban-circle"></i> <%=raw translation('tag.blog.spam') %></a>
          <% end %>
        </div>
        <hr />
      <% end %>

    <div class="text-center">
      <% if @pagy %>
        <%== pagy_bootstrap_nav @pagy %>
      <% else %>
        <%= will_paginate @notes, renderer: WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated %>
      <% end %>
    </div>

  <% end %>

  <hr />

</div>

